CREATE PROCEDURE coreCmsCheckin
(
	@cid			int,
	@OwnerID		int,
	@Notes			ntext
)
AS
BEGIN
	SET NOCOUNT ON;

	/* Declarations */
	DECLARE		@versionID	int;
	
	/* Get the version record id */
	SELECT @versionID = ISNULL(FK_VersionV, -1) FROM Content WHERE PK_ID=@cid;
	
	/* UPDATE THE RECORDS */
	UPDATE Content SET
		WorkflowStatus	=	1,
		FK_CheckedOutTo	=	-1
	WHERE PK_ID=@cid;
	
	UPDATE ContentV SET
		FK_CheckedInBy	=	@OwnerID,
		CheckedInDT		=	GETDATE(),
		VersionNotes	=	@Notes
	WHERE PK_ID=@versionID;

	SET NOCOUNT OFF;	
END